﻿using House.Server.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace House.Server.WebApi.ViewModel
{
    public static class RoleViewModel
    {
       
        /// <summary>
        /// 显示所有角色
        /// </summary>
        /// <returns></returns>
        public static dynamic SelectRole()
        {
            /// <summary>
            /// 调用角色BLL中所有方法
            /// </summary>
            Service.System_RoleService Role = new Service.System_RoleService();
            return Role.Select();
        }
        /// <summary>
        /// 删除选中角色
        /// </summary>
        /// <returns></returns>
        public static dynamic RoleDelete(int id)
        {
            /// <summary>
            /// 调用角色BLL中所有方法
            /// </summary>
            Service.System_RoleService Role = new Service.System_RoleService();
            return Role.DeleteById(id);
        }

        /// <summary>
        /// 添加角色
        /// </summary>
        /// <returns></returns>
        public static dynamic RoleAdd(Role list)
        {
            /// <summary>
            /// 调用角色BLL中所有方法
            /// </summary>
            Service.System_RoleService Role = new Service.System_RoleService();
            return Role.Insert(list);
        }

        /// <summary>
        /// 显示角色(根据Id查询)
        /// </summary>
        /// <returns></returns>
        public static dynamic RoleSelect1(int id)
        {
            /// <summary>
            /// 调用角色BLL中所有方法
            /// </summary>
            Service.System_RoleService Role = new Service.System_RoleService();
           // List<Role> list = Role.Select();
           // Role lists = list.Where(p => (p.R_id==id)).FirstOrDefault();
            return Role.Select(p=>p.R_id==id);
        }
        /// <summary>
        /// 修改信息角色
        /// </summary>
        /// <returns></returns>


        public static dynamic RoleUpdate(Role list)
        {
            /// <summary>
            /// 调用部门BLL中所有方法
            /// </summary>
            Service.System_RoleService Role = new Service.System_RoleService();
            return Role.Update(list);
        }

        /// <summary>
        /// 显示角色(查询未删除的角色)
        /// </summary>
        /// <returns></returns>
        public static dynamic RoleSelect2(int id)
        {
            /// <summary>
            /// 调用角色BLL中所有方法
            /// </summary>
            Service.System_RoleService Role = new Service.System_RoleService();
         
            return Role.Select(p => p.R_del == id);
        }
        public static dynamic RoleNameSelectByID(int id)
        {
            /// <summary>
            /// 调用角色BLL中所有方法
            /// </summary>
            Service.System_RoleService Role = new Service.System_RoleService();

            return Role.Select(p => p.R_id == id);
        }

    }
}